// pages/home/components/shareSpice/shareSpice.js
var app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
      "spec":{type :Object}
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   * 
   */

   attached(){
    app.func.getPromise('/list/zone')
    .then(([code, res]) => {
        this.setData({zone: res.data});
        let arr =[]
        this.data.zone.forEach((item,index) =>{
          console.log(item)
          console.log(index)
          arr.push(item.sku)
          this.setData({
            sku:arr
          });
        })
        console.log(this.data.sku)
    })
   
   },


  methods: {
    productdetail: function (e) {
			var id = e.currentTarget.dataset.id;
			wx.navigateTo({
				url: '/pages/index/productdetail/productdetail?id=' + id
			})
    },
    addcart:function(e){
			console.log('111')
			console.log(this.data.gifts)
				let id = e.currentTarget.dataset.id;
						app.func.postPromise('/addcartv2',
										{
												pro_id:id,
												count:1
										})  .then(([code, res]) => {
												console.log(res);
												if(code == 200){
														app.func.toastPromise('加入购物车成功','none',  500)
														.then(()=>{
													
														})
														this.setData({
															noaddcart:false
														})
												}else{
														wx.showToast({
															title:res.message,
															icon:'none',
															mask:true
														})
												}
										})
		
		},
  }
})
